//#pragma once
#ifndef VLARE_H
#define VLARE_H

#ifndef NOSTDAFX
#include "StdAfx.h"
#endif

#include "DynamicData.h"
#include "Element.h"
#include "Hook.h"


#include <vector>
// TODO: Serialisation

class Hook;

class Vlare
{
protected:
	Vlare(void);
	virtual ~Vlare(void);
public:
	class Element;

	virtual void Init(VlareHashMap properties) = 0;
	virtual void AcquireResources() = 0;
	virtual void FreeResources() = 0;
	virtual void Free() = 0;

	virtual void RunFrame() = 0;	//< Call this in your mainloop

	virtual Element* AddElement(Element *const pParent, ElementMemberMap props) = 0;
	virtual Element *const GetRoot() = 0;
	virtual void BringToFront(const Element*) = 0;
	virtual void DeleteElement(const Element*) = 0;

	//Vector<CollisionInfo*> PointsOverWhich();
	//CollisionInfo& PointsOver(const Element* const pElem, const bool bCheckChildren);
	//void TransformPoints(Coord2D_si* const paResults, const Coord2D_si* const paPoints, const unsigned int uiNoOfPoints, const Element* const pFrom, const Element* const pTo);


	virtual DynamicData::VLARE_TYPE IsHook(const char *const szFunction) = 0;
	/**
	 * Won't return DynamicData of type VlareFunction; VlareFunctions are resolved to their returnvalues.
	 */
	virtual DynamicData GetHook(Element *pElem, const char *const szName, DynamicData *params = (DynamicData*)0x0) = 0;

	/**
	 * Once a VlareFunction is set you can unset it using UnsetHook.
	 * When a VlareFunction is set twice, the two functions are called after each other, a table is returned.
	 * When a Value is set twice it is overidden
	 * However, this behaviour can be changed using MetaHooks
	 * For values, that should be static over one frame, caching can be enabled (only has effect on VlareFunctions). This ensures, that e.g. a mouseposition-variable does not change within one frame! On the other hand side timing-variables for profiling need to disable caching.
	 */
	virtual void SetHook(Element *const pElem, const char *const szName, DynamicData val, bool bCacheValueForFrame=false) = 0;
	virtual void UnsetHook(Element *const pElem, const char *const szName, DynamicData val) = 0;

	/**
	 * the VlareFunction is called with all the DynamicValues, of the set value. 
	 * //Please e-mail me, if this feature is required! (can't really imagine a use-case)
	 */
	//void SetMetaHook(Element* elem, const char* const szName, VlareFunction pfn);
};

typedef Vlare::Element Element;

#endif
